/*
 * File: FltLevelSettingCT.c
 *
 * Code generated for Simulink model 'FLTM'.
 *
 * Model version                  : 3.568
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Tue Mar 29 10:27:38 2022
 */

#include "FltLevelSettingCT.h"

/* Named constants for Chart: '<S67>/FetLevelSetCT' */
#define IN_Err_LV1                     ((uint8_T)1U)
#define IN_Err_LV2                     ((uint8_T)2U)
#define IN_Err_LV3                     ((uint8_T)3U)
#define IN_Err_Nor_p                   ((uint8_T)4U)
#define IN_FltJudge_b                  ((uint8_T)1U)
#define IN_Init_h                      ((uint8_T)2U)
#define IN_NO_ACTIVE_CHILD_n           ((uint8_T)0U)

/*
 * Output and update for atomic system:
 *    'FetLevelSetCT' ('mylib:235')
 *    'FetLevelSetCT' ('mylib:235')
 *    'FetLevelSetCT' ('FLTM:13730:235')
 *    'FetLevelSetCT' ('FLTM:13731:235')
 *    'FetLevelSetCT' ('mylib:235')
 *    'FetLevelSetCT' ('mylib:235')
 *    'FetLevelSetCT' ('mylib:235')
 *    'FetLevelSetCT' ('FLTM:13718:235')
 *    'FetLevelSetCT' ('FLTM:13719:235')
 *    'FetLevelSetCT' ('FLTM:13718:235')
 *    ...
 */
void FltLevelSettingCT(boolean_T LV1Cfm, boolean_T LV1Cel, boolean_T LV2Cfm,
                       boolean_T LV2Cel, boolean_T LV3Cfm, boolean_T LV3Cel,
                       B_FltLevelSettingCT_T *localB, DW_FltLevelSettingCT_T
                       *localDW, uint8_T rtp_Flttye, boolean_T *rtd_ClearFault)
{
    boolean_T tmp;
    if (localDW->is_active_c4_mylib == 0U)
    {
        localDW->is_active_c4_mylib = 1U;
        localDW->is_c4_mylib = IN_Init_h;
        localB->ScFlt_LV = 0U;
    }
    else if (localDW->is_c4_mylib == IN_FltJudge_b)
    {
        if (*rtd_ClearFault)
        {
            localDW->is_FltJudge = IN_NO_ACTIVE_CHILD_n;
            localDW->is_c4_mylib = IN_Init_h;
            localB->ScFlt_LV = 0U;
        }
        else
        {
            switch (localDW->is_FltJudge)
            {
              case IN_Err_LV1:
                localB->ScFlt_LV = 1U;
                if (LV3Cfm)
                {
                    localDW->is_FltJudge = IN_Err_LV3;
                    localB->ScFlt_LV = 3U;
                }
                else if (LV2Cfm)
                {
                    localDW->is_FltJudge = IN_Err_LV2;
                    localB->ScFlt_LV = 2U;
                }
                else
                {
                    if (LV1Cel)
                    {
                        localDW->is_FltJudge = IN_Err_Nor_p;
                        localB->ScFlt_LV = 0U;
                    }
                }
                break;

              case IN_Err_LV2:
                localB->ScFlt_LV = 2U;
                if (LV3Cfm)
                {
                    localDW->is_FltJudge = IN_Err_LV3;
                    localB->ScFlt_LV = 3U;
                }
                else if (LV2Cel && (!LV1Cfm))
                {
                    localDW->is_FltJudge = IN_Err_Nor_p;
                    localB->ScFlt_LV = 0U;
                }
                else
                {
                    if (LV2Cel)
                    {
                        localDW->is_FltJudge = IN_Err_LV1;
                        localB->ScFlt_LV = 1U;
                    }
                }
                break;

              case IN_Err_LV3:
                localB->ScFlt_LV = 3U;
                tmp = !LV2Cfm;
                if (LV3Cel && (!LV1Cfm) && tmp)
                {
                    localDW->is_FltJudge = IN_Err_Nor_p;
                    localB->ScFlt_LV = 0U;
                }
                else if (LV3Cel && LV1Cfm && tmp)
                {
                    localDW->is_FltJudge = IN_Err_LV1;
                    localB->ScFlt_LV = 1U;
                }
                else
                {
                    if (LV3Cel)
                    {
                        localDW->is_FltJudge = IN_Err_LV2;
                        localB->ScFlt_LV = 2U;
                    }
                }
                break;

              default:
                /* case IN_Err_Nor: */
                localB->ScFlt_LV = 0U;
                if (LV3Cfm)
                {
                    localDW->is_FltJudge = IN_Err_LV3;
                    localB->ScFlt_LV = 3U;
                }
                else if (LV2Cfm)
                {
                    localDW->is_FltJudge = IN_Err_LV2;
                    localB->ScFlt_LV = 2U;
                }
                else
                {
                    if (LV1Cfm)
                    {
                        localDW->is_FltJudge = IN_Err_LV1;
                        localB->ScFlt_LV = 1U;
                    }
                }
                break;
            }
        }
    }
    else
    {
        /* case IN_Init: */
        localB->ScFlt_LV = 0U;
        if ((rtp_Flttye == 1) && (!*rtd_ClearFault))
        {
            localDW->is_c4_mylib = IN_FltJudge_b;
            localDW->is_FltJudge = IN_Err_Nor_p;
            localB->ScFlt_LV = 0U;
        }
    }
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
